package main

import (
	"github.com/name5566/leaf"
	"lol.com/feb214-game/nest.git/heartbeat"
	"lol.com/feb214-game/nest.git/log"
	"talent.com/cube/common/cache"
	"talent.com/cube/conf"
	"talent.com/cube/conf/g"
	"talent.com/cube/modules/admin"
	"talent.com/cube/modules/api"
	"talent.com/cube/modules/game"
	"talent.com/cube/modules/gate"
)

func onClose() {
	conf.CloseAll()
	log.Info("all closed")
	log.CloseLogger()
}

func main() {
	conf.InitConfig()
	conf.InitDurotar()
	cache.InitRobots()
	g.CleanLoginInfo()
	if conf.ServerConfig().Game.TestMode {
		log.Warn("NOTE: test mode is on")
	}
	defer onClose()
	//析构的时候是从后到前的
	leaf.Run(
		heartbeat.Module,
		gate.Module,
		game.Module,
		api.Module,
		admin.Module,
	)
}
